package com.t235.gc.biz.service.impl;

import com.t235.gc.entity.GarbageTypeStatistics;
import com.t235.gc.dao.GarbageTypeStatisticsDao;
import com.t235.gc.biz.service.GarbageTypeStatisticsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 垃圾类型统计表(GarbageTypeStatistics)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:31
 */
@Service("garbageTypeStatisticsService")
public class GarbageTypeStatisticsServiceImpl implements GarbageTypeStatisticsService {
    @Resource
    private GarbageTypeStatisticsDao garbageTypeStatisticsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param statisticsid 主键
     * @return 实例对象
     */
    @Override
    public GarbageTypeStatistics queryById(Long statisticsid) {
        return this.garbageTypeStatisticsDao.queryById(statisticsid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GarbageTypeStatistics> queryAllByLimit(int offset, int limit) {
        return this.garbageTypeStatisticsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param garbageTypeStatistics 实例对象
     * @return 实例对象
     */
    @Override
    public GarbageTypeStatistics insert(GarbageTypeStatistics garbageTypeStatistics) {
        this.garbageTypeStatisticsDao.insert(garbageTypeStatistics);
        return garbageTypeStatistics;
    }

    /**
     * 修改数据
     *
     * @param garbageTypeStatistics 实例对象
     * @return 实例对象
     */
    @Override
    public GarbageTypeStatistics update(GarbageTypeStatistics garbageTypeStatistics) {
        this.garbageTypeStatisticsDao.update(garbageTypeStatistics);
        return this.queryById(garbageTypeStatistics.getStatisticsid());
    }

    /**
     * 通过主键删除数据
     *
     * @param statisticsid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long statisticsid) {
        return this.garbageTypeStatisticsDao.deleteById(statisticsid) > 0;
    }
}
